package com.turing.post.tuxedo.util;

import java.io.Serializable;
import java.math.BigInteger;

import org.jdom2.Element;

import com.turing.post.util.PCPSApplicationException;

/**
 * 充值交易输入
 * 
 * @author yxb
 * 
 */
@SuppressWarnings("serial")
public class IDeposit extends TransRequest implements Serializable {
	/**
	 * 充值对象
	 */
	public CardObj cardObj = new CardObj();

	/**
	 * 发生额
	 */
	public BigInteger amount = BigInteger.ZERO;

	/**
	 * 业务摘要或备注(可选)
	 */
	public String asbtract = null;

	/**
	 * 产生计算MAC的域
	 */
	@Override
	protected void generateMacField() {
		appendMacField(cardObj.cardNo);
	}

	/**
	 * 解析交易请求私有报文体
	 * 
	 * @param reqBody
	 * @throws Exception
	 */
	@Override
	protected void parseReqBodyXml(Element reqBody)
			throws PCPSApplicationException {
		// Card
		Element elnode = reqBody.getChild(TransXmlHelper.XML_NODE_Card);
		if (elnode == null)
			ParaseException.TransParamException("not found Card!");

		// 卡对象
		cardObj.parseCardObj(elnode, true);

		// 发生额
		amount = TransXmlHelper.getInteger(elnode,
				TransXmlHelper.XML_NODE_Amount);

		// 业务摘要或备注(可选)
		asbtract = TransXmlHelper.getOptionalString(reqBody,
				TransXmlHelper.XML_NODE_Asbtract);
	}
}
